﻿namespace Blaze.ConfigExporters
{
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using Aspose.Cells;
    using ConfigExportTool;

    /// <summary>
    /// 导出异常：重复的翻译字段。
    /// </summary>
    public class DuplicatedTranslationException : ExportException
    {
        public DuplicatedTranslationException()
            : base(null)
        {
        }

        public void Add(Cell IdCell)
        {
            mCells.Add(IdCell);
        }

        protected override void AppendDetailMessage(StringBuilder buffer)
        {
            buffer.Append("翻译字段冲突\r\n");
            foreach (var cell in mCells)
                buffer.AppendFormat("ID={0} -> {1}\r\n", cell.StringValue, Path.GetFileName(cell.Worksheet.Workbook.FileName));
        }

        private readonly List<Cell> mCells = new List<Cell>();
    }
}